# Test API Endpoints

$baseUrl = "http://localhost:8082/api/voiceprint"

Write-Host "=== Testing API Endpoints ==="

# Test 1: Check if server is running
Write-Host "Test 1: Checking server status..."
try {
    $response = Invoke-WebRequest -Uri "http://localhost:8082" -Method GET -TimeoutSec 5
    Write-Host "Server is running. Status: $($response.StatusCode)"
} catch {
    Write-Host "Server connection failed: $($_.Exception.Message)"
}

# Test 2: List groups
Write-Host "`nTest 2: Listing voiceprint groups..."
try {
    $listUrl = "$baseUrl/group/list"
    $response = Invoke-RestMethod -Uri $listUrl -Method GET -ContentType "application/json"
    Write-Host "Groups list successful!"
    Write-Host "Response: $($response | ConvertTo-Json -Depth 3)"
} catch {
    Write-Host "Groups list failed: $($_.Exception.Message)"
}

# Test 3: Get group info
Write-Host "`nTest 3: Getting group info..."
try {
    $groupUrl = "$baseUrl/group/info?groupId=test_group_real_mp3"
    $response = Invoke-RestMethod -Uri $groupUrl -Method GET -ContentType "application/json"
    Write-Host "Group info successful!"
    Write-Host "Response: $($response | ConvertTo-Json -Depth 3)"
} catch {
    Write-Host "Group info failed: $($_.Exception.Message)"
}

Write-Host "`n=== API Endpoint Tests Completed ==="